package com.hit.demo1.controller;

import com.alibaba.fastjson.JSON;
import com.hit.demo1.entity.E_Stu;
import com.hit.demo1.param.StuParam;
import com.hit.demo1.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class Hello {

    @Autowired
    public StuService stuService;

    /**
    @GetMapping("/findall")
    @ResponseBody
    public String findAll(StuParam stuParam){
        return stuService.findAll(stuParam).toString();
    }*/

    @GetMapping("/save")
    @ResponseBody
    public String save(E_Stu stu){
        return stuService.save(stu).toString();
    }

    @GetMapping("/delete")
    @ResponseBody
    public String delete(Integer id){
        stuService.delete(id);
        return "ok";
    }
    @GetMapping("/findSclass")
    @ResponseBody
    public List<E_Stu> findSclass(String sclass) {
        return stuService.findAllBySclass(sclass);

    }
    @GetMapping("/findSclassLike")
    @ResponseBody
    public String findAllBySclassLike(String sclass) {
        return JSON.toJSONString(stuService.findAllBySclassLike(sclass));

    }
    @GetMapping("/findSclass&Saddress")
    @ResponseBody
    public String findAllBySaddressAndSclassOrderBySid(String saddress, String sclass) {
        return stuService.findAllBySaddressAndSclassOrderBySid(saddress, sclass).toString();

    }
    @GetMapping("/insert")
    @ResponseBody
    public String insertNum(int number){
        stuService.insertNum(number);
        return "success";
    }
//    @GetMapping("/findallpage")
//    @ResponseBody
//    public Page findAll(StuParam stuParam, int page, int limit){
//        return stuService.findAll(stuParam, page, limit);
//    }
}
